package org.hydrakyoufeng.qiniu;


import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


@Configuration
public class QiniuConfig {

    /**
     * 七牛云参数
     */
    public class QiniuProperties{
    	
        private String accessKey;

        private String secretKey;

        private String bucket;

        private String remoteAddr;
        
        /**
         * 过期时间：秒
         */
        private Integer expire = 3600;

		public String getAccessKey() {
			return accessKey;
		}

		public void setAccessKey(String accessKey) {
			this.accessKey = accessKey;
		}

		public String getSecretKey() {
			return secretKey;
		}

		public void setSecretKey(String secretKey) {
			this.secretKey = secretKey;
		}

		public String getBucket() {
			return bucket;
		}

		public void setBucket(String bucket) {
			this.bucket = bucket;
		}

		public String getRemoteAddr() {
			return remoteAddr;
		}

		public void setRemoteAddr(String remoteAddr) {
			this.remoteAddr = remoteAddr;
		}

		public Integer getExpire() {
			return expire;
		}

		public void setExpire(Integer expire) {
			this.expire = expire;
		}
        
    }

    /**
     * 获取一个公开空间七牛云参数对象
     * ConfigurationProperties注解：读取配置文件中的前缀为qiniu的参数
     * @return
     */
    @Bean
    @ConfigurationProperties(prefix = "qiniu")
    public QiniuProperties qiniuProperties(){
        return new QiniuProperties();
    }

    /**
     * 获取一个私有空间七牛云参数对象
     * ConfigurationProperties注解：读取配置文件中的前缀为qiniu的参数
     * @return
     */
    @Bean
    @ConfigurationProperties(prefix = "qiniu-secret")
    public QiniuProperties qiniuSecretProperties(){
        return new QiniuProperties();
    }
}
